00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 class GallerySettings {
00029 var $maxwidth;
00030 var $maxheight;
00031 var $maxfilesize;
00032 var $maximages;
00033 var $slidetime;
00034
00038 function GallerySettings() {
00039 global $db;
00040
00041 $dbentry = $db->get_row("SELECT * FROM photogallery_settings WHERE course_id={$_SESSION['course']}");
00042 if ($dbentry) {
00043 $this->maxwidth = $dbentry->maxwidth;
00044 $this->maxheight = $dbentry->maxheight;
00045 $this->maxfilesize = $dbentry->maxfilesize;
00046 $this->maximages = $dbentry->maximages;
00047 $this->slidetime = $dbentry->slidetime;
00048 } else {
00049 $this->maxwidth = 1024;
00050 $this->maxheight = 768;
00051 $this->maxfilesize = 2.5;
00052 $this->maximages = 0;
00053 $this->slidetime = 10;
00054 }
00055 }
00056
00063 function secureAssign(&$localvar, &$DATA_postvar) {
00064 if ($DATA_postvar->IsValid()) $localvar = $DATA_postvar->data;
00065 }
00066
00074 function ProcessInput() {
00075 if ($_SESSION['usergroup'] == ADMIN || $_SESSION['usergroup'] == DOZENT) {
00076 if (isset($_POST['storesettings'])) {
00077 $this->secureAssign($this->maxwidth, new IntegerNumberData($_POST['setting_maxwidth']));
00078 $this->secureAssign($this->maxheight, new IntegerNumberData($_POST['setting_maxheight']));
00079 $this->secureAssign($this->maxfilesize, new FloatNumberData($_POST['setting_maxfilesize']));
00080 $this->secureAssign($this->maximages, new IntegerNumberData($_POST['setting_maximages']));
00081 $this->secureAssign($this->slidetime, new IntegerNumberData($_POST['setting_slidetime']));
00082 $this->maxfilesize = str_replace(',', '.', $this->maxfilesize);
00083
00084 if ($this->maxwidth < 1) $this->maxwidth = 1;
00085 if ($this->maxwidth > 4096) $this->maxwidth = 4096;
00086 if ($this->maxheight < 1) $this->maxheight = 1;
00087 if ($this->maxheight > 4096) $this->maxheight = 4096;
00088 if ($this->maxfilesize < 0.1) $this->maxfilesize = 0.1;
00089 if ($this->maxfilesize > 20.0) $this->maxfilesize = 20.0;
00090 if ($this->maximages < 0) $this->maximages = 0;
00091 if ($this->maximages > 9999) $this->maximages = 9999;
00092 if ($this->slidetime < 0) $this->slidetime = 0;
00093 if ($this->slidetime > 240) $this->slidetime = 240;
00094
00095 global $db;
00096 $db->query("DELETE FROM photogallery_settings WHERE course_id=$_SESSION[course]");
00097 $db->query("INSERT INTO photogallery_settings (course_id,maxwidth,maxheight,maxfilesize,maximages,slidetime) VALUES ($_SESSION[course],{$this->maxwidth},{$this->maxheight},{$this->maxfilesize},{$this->maximages},{$this->slidetime})");
00098
00099 }
00100 }
00101 }
00102
00106 function ProcessForm() {
00107 $this->ProcessInput();
00108 $this->PrintForm();
00109 }
00110
00116 function PrintForm() {
00117 $maxfilesize = str_replace('.', ',', $this->maxfilesize);
00118 print "<form method='post' action='".PATH_TO_ROOT.SCRIPT_NAME."'>
00119 <table width='100%' cellspacing='2' cellpadding='3'>
00120
00121 <tr>
00122 <td class='tableCell' style='width:50%;text-align:right;'> Maximale Bildbreite</td>
00123 <td class='tableCell'> <p class='pForm'><input type='text' name='setting_maxwidth' value='{$this->maxwidth}' style='width:5em'/> Pixel</p> </td>
00124 </tr>
00125 <tr>
00126 <td class='tableCell' style='width:50%;text-align:right;'> Maximale Bildhöhe</td>
00127 <td class='tableCell'> <p class='pForm'><input type='text' name='setting_maxheight' value='{$this->maxheight}' style='width:5em'/> Pixel</p> </td>
00128 </tr>
00129 <tr>
00130 <td class='tableCell' style='width:50%;text-align:right;'> Maximale Bildgröße</td>
00131 <td class='tableCell'> <p class='pForm'><input type='text' name='setting_maxfilesize' value='{$maxfilesize}' style='width:5em'/> MB</p> </td>
00132 </tr>
00133 <tr>
00134 <td class='tableCell' style='width:50%;text-align:right;'> Max. Anzahl Bilder pro Album</td>
00135 <td class='tableCell'> <p class='pForm'><input type='text' name='setting_maximages' value='{$this->maximages}' style='width:5em'/> (0 = unbegrenzt)</p> </td>
00136 </tr>
00137 <tr>
00138 <td class='tableCell' style='width:50%;text-align:right;'> Anzeigedauer eines Bildes der Slideshow</td>
00139 <td class='tableCell'> <p class='pForm'><input type='text' name='setting_slidetime' value='{$this->slidetime}' style='width:5em'/> Sekunden (0 = unbegrenzt)</p> </td>
00140 </tr>";
00141 echo "<tr><td class='tableCellDark' colspan='5' style='text-align:center;'><input type='submit' name='storesettings' value='Speichern'/></td></tr>";
00142 echo "</table></form>";
00143 }
00144
00146 function get_maxwidth() {
00147 return $this->maxwidth;
00148 }
00149
00151 function get_maxheight() {
00152 return $this->maxheight;
00153 }
00154
00156 function get_maxfilesize() {
00157 return $this->maxfilesize*1024*1024;
00158 }
00159
00161 function get_maximages() {
00162 return $this->maximages;
00163 }
00164
00166 function get_slidetime() {
00167 return $this->slidetime;
00168 }
00169 }
00170 $photosettings = new GallerySettings();